import { Comparable, AbstractModel } from "../types";
import { numberToHash, formatToString } from "../utils";
/**
 * 模型：数字,
 * 属性：数字,
 */
export class MyNumber extends AbstractModel implements Comparable<MyNumber> {
  static common(data: number): MyNumber {
    return new MyNumber(data);
  }
  constructor(private _number: number) {
    super();
  }
  get number(): number {
    return this._number;
  }
  get hash(): number {
    return numberToHash(this._number);
  }
  equals(obj: unknown): boolean {
    return this._number === obj;
  }
  compareTo(obj: MyNumber): number {
    return this._number - obj._number;
  }
  toString(): string {
    return formatToString("MyNumber", ["number", this.number]);
  }
}
